﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;

public partial class Controls_SearchBoxl : System.Web.UI.UserControl
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        btnSearch.Click += new EventHandler(btnSearch_Click); 
    }
    
    void btnSearch_Click(object sender, EventArgs e) 
    { 
        string searchString = txtKey.Text.Trim();
        string giaDuoi = txtGiaDuoi.Text.Trim();
        string giaTren = txtGiaTren.Text.Trim();
        try
        {
            int gd, gt;

            try
            {
                gd = int.Parse(giaDuoi);
            }
            catch
            {
                gd = -1;
            }
            try
            {
                 gt = int.Parse(giaTren);
            }
            catch 
            {
                gt = 12345;
            }

            if (searchString.Length > 0 || gd != -1 || gt != 12345)
                Response.Redirect(Link.ToSearch(searchString, gd, gt, "1"));
        }
        catch
        {            
        }
        
    }
}